<html>
<head><meta charset="utf-8"><title>how to debug assertion? · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html">how to debug assertion?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="199042910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199042910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Roland Kuhn <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199042910">(May 28 2020 at 16:05)</a>:</h4>
<p>I’m hitting <a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_hir_ty/src/lib.rs#L524">this assertion</a> with left=1 and right=2 (in a moderately complex codebase, of course, that is not yet public). Any ideas on how to proceed?</p>



<a name="199043198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199043198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199043198">(May 28 2020 at 16:07)</a>:</h4>
<p>The first thing to do would be to summon <span class="user-mention" data-user-id="129457">@Florian Diebold</span> :P</p>
<p>Then, run <code>rust-analyzer analysis-stats .</code>  (batch analysis) to check if it reproduces the problem reliably</p>



<a name="199043217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199043217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199043217">(May 28 2020 at 16:07)</a>:</h4>
<p>if it does, the next thing to do would be to minize the test case</p>



<a name="199043589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199043589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Roland Kuhn <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199043589">(May 28 2020 at 16:10)</a>:</h4>
<p>ah, so how do I run rust-analyzer again? (now on Linux … )</p>



<a name="199043622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199043622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199043622">(May 28 2020 at 16:11)</a>:</h4>
<p>yeah, that. if analysis-stats crashes, you should be able to see the last function it was analyzing, and then you can run it with <code>-o that_function</code> to only analyze one function, which should be much faster and still crash</p>



<a name="199043704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199043704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199043704">(May 28 2020 at 16:11)</a>:</h4>
<p>you should be able to run it from wherever VSCode downloaded it (someone who knows about VSCode can probably tell us the path)</p>



<a name="199043759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199043759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Roland Kuhn <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199043759">(May 28 2020 at 16:12)</a>:</h4>
<p>hmm, looking …</p>



<a name="199043843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199043843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199043843">(May 28 2020 at 16:13)</a>:</h4>
<p><a href="https://rust-analyzer.github.io/manual.html#vs-code">https://rust-analyzer.github.io/manual.html#vs-code</a></p>



<a name="199043869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199043869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199043869">(May 28 2020 at 16:13)</a>:</h4>
<p><code>~/.config/Code/User/globalStorage/matklad.rust-analyzer/rust-analyzer-linux </code></p>



<a name="199043929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199043929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199043929">(May 28 2020 at 16:13)</a>:</h4>
<p>Don't we rename it to <code>rust-analyzer</code>? <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="199044026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199044026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Roland Kuhn <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199044026">(May 28 2020 at 16:14)</a>:</h4>
<p>there is no <code>~/.config/Code</code> … I’m running this via Code server remote</p>



<a name="199044039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199044039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199044039">(May 28 2020 at 16:14)</a>:</h4>
<p>you could also just download the binary from github and put it anywhere though</p>



<a name="199044563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199044563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Roland Kuhn <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199044563">(May 28 2020 at 16:18)</a>:</h4>
<p>(downloaded the binary because I couldn’t find it on that host)</p>
<div class="codehilite"><pre><span></span><code>Database loaded, 251 roots, 376.796722ms
Crates in this dir: 1
Total modules found: 33
Total declarations: 478
Total functions: 319
Item Collection: 14.546484276s, 0b allocated 0b resident
50/319 15% processing: util::flow::distinctthread &#39;main&#39; panicked at &#39;assertion failed: `(left == right)`
  left: `1`,
 right: `2`&#39;, crates/ra_hir_ty/src/lib.rs:524:9
</code></pre></div>


<p>so I guess that points me to the <code>distinct</code> method I happen to have on my <code>Flow</code> in the <code>flow</code> module, right?</p>



<a name="199044615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199044615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199044615">(May 28 2020 at 16:19)</a>:</h4>
<p>yes. so <code>-o util::flow::distinct</code> should also crash</p>



<a name="199044764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199044764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Roland Kuhn <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199044764">(May 28 2020 at 16:20)</a>:</h4>
<p>the thing is I have multiple <code>distinct</code> methods on different types in that module</p>



<a name="199044857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199044857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199044857">(May 28 2020 at 16:21)</a>:</h4>
<p>hmm yeah that's not ideal, you could try giving them unique names? unless it changes the name resolution inside the function it should probably still reproduce the crash</p>



<a name="199044958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199044958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Roland Kuhn <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199044958">(May 28 2020 at 16:21)</a>:</h4>
<p>yes, that crashes as well; I have several errors (am in the middle of a refactoring), will see if fixing the errors removes this crash</p>



<a name="199046392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199046392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Roland Kuhn <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199046392">(May 28 2020 at 16:32)</a>:</h4>
<p><span class="user-mention" data-user-id="129457">@Florian Diebold</span> So I have a trait <code>Flow&lt;'a, T&gt;</code> and I added another type parameter to it. Several methods needed updated type signatures, and after I’d done those the crash went away.</p>



<a name="199046477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199046477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Roland Kuhn <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199046477">(May 28 2020 at 16:33)</a>:</h4>
<p>now I still have many errors related to this change in other modules, but those don’t crash the analyzer</p>



<a name="199046516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199046516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199046516">(May 28 2020 at 16:34)</a>:</h4>
<p>hm yeah it's probably not as straightforward as having a trait and using it with the wrong number of type parameters</p>



<a name="199046639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199046639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Roland Kuhn <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199046639">(May 28 2020 at 16:34)</a>:</h4>
<p>not sure whether you are being ironic</p>



<a name="199046716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199046716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Roland Kuhn <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199046716">(May 28 2020 at 16:35)</a>:</h4>
<p>of course I need to fix my type errors, but the analyzer crashing makes that experience quite a bit more annoying; the primary reason to use rust-analyzer is that it so awesomely supports refactorings</p>



<a name="199046885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199046885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199046885">(May 28 2020 at 16:37)</a>:</h4>
<p>I'm not being ironic, I'm pretty sure this has to be a bit more complicated</p>



<a name="199046941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199046941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199046941">(May 28 2020 at 16:37)</a>:</h4>
<p>yeah, this is a bug we need to fix, doesn't matter whether there are type errors or not</p>



<a name="199047424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199047424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199047424">(May 28 2020 at 16:41)</a>:</h4>
<p>or, maybe not complicated, but some edge case...</p>



<a name="199047998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199047998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Roland Kuhn <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199047998">(May 28 2020 at 16:46)</a>:</h4>
<p>Ah, yes, makes sense (I don’t know you well enough yet, so had to ask). I’m making such changes often and this was the first one to crash; perhaps the lifetime parameter plays into it.</p>



<a name="199048144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/how%20to%20debug%20assertion%3F/near/199048144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Roland Kuhn <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/how.20to.20debug.20assertion.3F.html#199048144">(May 28 2020 at 16:47)</a>:</h4>
<p>I’ll try to minimize later, now I need to finish that one feature (as always)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>